package makabakaquestionnaire.zutsoftware.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import makabakaquestionnaire.zutsoftware.entity.ProjectResult;
import makabakaquestionnaire.zutsoftware.entity.request.QueryResultRequest;
import makabakaquestionnaire.zutsoftware.mapper.ProjectResultMapper;
import makabakaquestionnaire.zutsoftware.service.ProjectResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProjectResultServiceImpl implements ProjectResultService {
    ProjectResultMapper projectResultMapper;
    @Autowired
    public void setProjectResultMapper(ProjectResultMapper projectResultMapper) {
        this.projectResultMapper = projectResultMapper;
    }

    @Override
    public Boolean saveProjectResult(ProjectResult projectResult) {
       int n= projectResultMapper.saveProjectResult(projectResult);
       if (n!=1){
           return false;
       }else {
           return true;
       }
    }

    @Override
    public PageInfo<ProjectResult> queryProjectByRequest(QueryResultRequest queryResultRequest) {
        PageHelper.startPage(queryResultRequest.getPageNum(),queryResultRequest.getPageSize());
        List<ProjectResult> projectResults=projectResultMapper.queryProjectByRequest(queryResultRequest);
        return new PageInfo<ProjectResult>(projectResults);
    }

    @Override
    public Long getResultMaxNum(String projectKey) {
      return   projectResultMapper.getResultMaxNum(projectKey);
    }

    @Override
    public List<ProjectResult> selectProjectResultList(QueryResultRequest queryResultRequest) {
        return projectResultMapper.queryProjectByRequest(queryResultRequest);
    }


}
